package com.wuseguang.springcloud.wxpay.sdk;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * @Title: mp-api
 * @Description:
 * @Author:tankejun
 * @Date: 2018/10/8 15:36
 * @Version： 1.0
 */
public class MyConfig extends WXPayConfig {


    private byte[] certData;


    public MyConfig() throws Exception {

        //不是沙箱环境要要下载证书，开出来
        //正式环境
        String certPath = "/mnt/WXPay/apiclient_cert.p12";
        //本地测试
        //String certPath = "C:\\Users\\Administrator\\Desktop\\1602901584_20200919_cert\\apiclient_cert.p12";

        File file = new File(certPath);

        InputStream certStream = new FileInputStream(file);

        this.certData = new byte[(int) file.length()];

        certStream.read(this.certData);

        certStream.close();

    }


    @Override
    String getAppID() {
        return "wx30b606bac7775eba";
    }

    @Override
    String getMchID() {
        return "1602901584";
    }

    @Override
    public String getKey() {
        return "344ce5d911234c0f9abae2d9d3f33462";
    }

    @Override
    InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }


    @Override
    IWXPayDomain getWXPayDomain() {
        return WXPayDomainSimpleImpl.instance();
    }

    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    public int getHttpReadTimeoutMs() {
        return 10000;
    }
}
